home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / matrx042.zip / MATDUMP.C < prev    next >
Text File  |  1992-05-25  |  2KB  |  78 lines

  1. /*
  2. *-----------------------------------------------------------------------------
  3. *    file:    matdump.c
  4. *    desc:    matrix mathematics - object dump
  5. *    by:    ko shu pui, patrick
  6. *    date:    24 nov 91 v0.1
  7. *    revi:    14 may 92 v0.2
  8. *    ref:
  9. *       [1] Mary L.Boas, "Mathematical Methods in the Physical Sciene,"
  10. *    John Wiley & Sons, 2nd Ed., 1983. Chap 3.
  11. *
  12. *    [2] Kendall E.Atkinson, "An Introduction to Numberical Analysis,"
  13. *    John Wiley & Sons, 1978.
  14. *
  15. *-----------------------------------------------------------------------------
  16. */
  17. #include <stdio.h>
  18. #include "matrix.h"
  19.  
  20. /*
  21. *-----------------------------------------------------------------------------
  22. *    funct:    mat_dump
  23. *    desct:    dump a matrix
  24. *    given:    A = matrice to dumped
  25. *    retrn:    nothing
  26. *    comen:    matrix a dumped to standard output
  27. *-----------------------------------------------------------------------------
  28. */
  29. MATRIX mat_dump( A )
  30. MATRIX A;
  31. {
  32.     return(mat_fdumpf(A, "%f ", stdout));
  33. }
  34.  
  35. /*
  36. *-----------------------------------------------------------------------------
  37. *    funct:    mat_dumpf
  38. *   desct:  dump a matrix with format string to standard output
  39. *    given:    A = matrice to dumped
  40. *    retrn:    nothing
  41. *    comen:    matrix a dumped to standard output
  42. *-----------------------------------------------------------------------------
  43. */
  44. MATRIX mat_dumpf( A, s )
  45. MATRIX A;
  46. char *s;
  47. {
  48.     return (mat_fdumpf(A, s, stdout));
  49. }
  50.  
  51. MATRIX mat_fdump( A, fp )
  52. MATRIX A;
  53. FILE *fp;
  54. {
  55.     return (mat_fdumpf(A, "%f ", fp));
  56. }
  57.  
  58. MATRIX mat_fdumpf( A, s, fp )
  59. MATRIX A;
  60. char *s;
  61. FILE *fp;
  62. {
  63.     int    i, j;
  64.  
  65.     for (i=0; i<MatRow(A); i++)
  66.         {
  67.         for (j=0; j<MatCol(A); j++)
  68.             {
  69.             fprintf( fp, s, A[i][j] );
  70.             }
  71.         fprintf( fp, "\n" );
  72.         }
  73.  
  74.     return (A);
  75. }
  76.  
  77.  
  78.